<div id="tb<?php echo $uniqid;?>">
    <table cellspacing="0" cellpadding="0">
        <tbody>
        <tr>
            <td><a href="javascript:void(0);" onclick="agentgoodsloggoodsReload();" class="l-btn l-btn-small l-btn-plain"><span
                    class="l-btn-left l-btn-icon-left"><i class="iconfont icon-shuaxin"></i><span class="l-btn-text">重载</span></span></a></td>
            <td><span style="line-height:30px;"></span>
                <input id="agentgoodsloggoodskeywords" style="width:120px" placeholder="按ID、商品名搜索" type="text"
                                   class="easyui-input textbox"></td>
            <td><a href="javascript:void(0);" onclick="agentgoodsloggoodsSearch();" class="l-btn l-btn-small l-btn-plain"><span
                    class="l-btn-left l-btn-icon-left"><i class="iconfont icon-sousuo"></i><span class="l-btn-text">查询</span></span></a></td>
        </tr>
        </tbody>
    </table>
</div>
<div class="con"  style="-moz-user-select:none;">
    <table id="agentgoodsloggoods"></table>
</div>
<div id="agentgoodsloggoodsDlg" class="easyui-dialog" style="width:840px; height:520px;" title="信息框" closed="true"></div>
<script>

    var agentgoodsloggoodsReload = function () {
        $("#agentgoodsloggoods").datagrid('reload');
    };
    var agentGoodsLogs = function (opt_id) {
        let title = '代理商品ID'+opt_id+'设置历史';
        addTab(title, '/admin/agentgoodslog/goodsloglist?id='+opt_id);
    };
    var agentgoodsloggoodsSearch = function () {
        var height = $(window).height() - $(".top").height() - 46;//表格高度
        var width = $(window).width() - $(".leftmenu").width() - 8;
        $("#agentgoodsloggoods").datagrid({
            title: '代理商品',
            width: width,
            height: height,//高度
            singleSelect: true,//如果为true，则只允许选择一行
            striped: true,//是否显示斑马线效果。
            rownumbers: false,//如果为true，则显示一个行号列。
            pagination: true,//是否显示分页
            pageSize: 15,
            pageList: [15, 30, 40, 50],
            method: 'post',
            sortName: 'weigh',
            sortOrder: 'desc',
            url: '/admin/agentgoodslog/goodslist',
            queryParams: {
                keywords: $('#agentgoodsloggoodskeywords').val(),
            },
            fitColumns: true,//真正的自动展开/收缩列的大小，以适应网格的宽度，防止水平滚动。
            nowrap: false,//如果为true，则在同一行中显示数据。设置为true可以提高加载性能。 是否换行
            selectOnCheck: false,
            checkOnSelect: false,
            idField: 'id',
            toolbar: '#tb<?php echo $uniqid;?>',
            rowStyler: function (index, row) {
                if (row.status == '失效') {
                    return 'color:#F00;font-style:italic;';
                }
            },
            columns: [[
                {field: 'id', title: '商品ID', width: fixWidth(5)},
                {
                    field: 'title', title: '商品信息', width: fixWidth(50), formatter: function (value, rowData, rowIndex) {
                        return '<div style="display: flex;align-items: center;">' +
                            '<img src="' + rowData.image + '?imageView2/1/w/60/h/60" style="height:30px;width:30px;border-radius: 5px;border:#dfdfdf 1px solid;">'+
                            '<div>' + value + "<br>" + (rowData.is_sku ? '（多规格）' : '') + '</div></div>';
                    }
                },
                {field: 'price', title: '价格', width: fixWidth(15), align:'center'},
                {field: 'status', title: '分红状态', width: fixWidth(15), align:'center', formatter: function (value, rowData, rowIndex) {
                    return value?'已参与':'未参与'
                    }},
                {
                    field: 'option', title: '操作', align:'center', width: fixWidth(15), formatter: function (value, rowData, rowIndex) {
                        let buttons = '<div class="table">';
                        buttons += '<span class="l-btn l-btn-small color9 table" onclick="agentGoodsLogs(\'' + rowData.id + '\')"><span class="l-btn-text">设置历史</span></span>';
                        return buttons + '</div>';
                    }
                },
            ]],
        });
    };
    agentgoodsloggoodsSearch();
    onDatagridResize("#agentgoodsloggoods");
</script>
